<?php
/*####################
# Klasa: DbConnector
# Opis: Konekcija so MySQL baza
#
####################*/


require_once('ConfClass.php');

class DbConnector extends ConfClass {

    var $theQuery;
    var $link;

    function DbConnector(){

        // zemanje na osnovnite setinzi
        $conf = ConfClass::getSettings();

        // zemanje na osnovnite setinzi
        $host = $conf['dbhost'];
        $db = $conf['dbname'];
        $user = $conf['dbusername'];
        $pass = $conf['dbpassword'];

        // konekcija so baza
        $this->link = mysql_connect($host, $user, $pass);
        mysql_select_db($db);
       // register_shutdown_function(array(&$this, 'close'));

    }

    //*** Funkcija: query - Izvrsuvanje na soodvetno query ***
    function query($query) {

        $this->theQuery = $query;
        return mysql_query($query, $this->link);

    }

    //*** Funckija: fetchArray - Zemanje na array od soodvetnotniot rezultat ***
    function fetchArray($result) {

        return mysql_fetch_array($result);

    }

    //*** Funckija: close - zatvoranje na konekcija ***
    function close() {

        mysql_close($this->link);

    }
}
?>